package com.qf.mrboot.controller;

import com.qf.mrboot.entity.Order;
import com.qf.mrboot.result.ResponseData;
import com.qf.mrboot.result.ResultCode;
import com.qf.mrboot.service.OrderService;
import com.qf.mrboot.util.SmsUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Order)表控制层
 *
 * @author makejava
 * @since 2021-06-02 09:43:57
 */
@RestController
@RequestMapping("order")
public class OrderController {
    /**
     * 服务对象
     */
    @Resource
    private OrderService orderService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Order selectOne(Integer id) {
        return this.orderService.queryById(id);
    }
    @GetMapping("sendSm/{tel}")
    public ResponseData sendSm(@PathVariable String tel){
        String code = SmsUtil.sendMs(tel);
        return new ResponseData(ResultCode.SUCCESS,code);
    }

    @ApiOperation(value="createOrder",notes = "添加预约记录")
    @PostMapping("createOrder")
    public ResponseData createOrder(@RequestBody Order order){
        return orderService.insert(order);

    }

}
